<template>
  <div id="app">
    <el-container>
      <el-header :style="[showSidebar ? center : {}]">
        <div class="logo">
          <img src="./assets/img/horLogo.webp" alt />
        </div>
        <el-menu
          v-if="!showSidebar"
          :default-active="defaultActive"
          class="el-menu-demo"
          mode="horizontal"
          :router="router"
          :ellipsis="false"
        >
          <el-menu-item index="/" class="item">首页</el-menu-item>
          <el-menu-item index="/news" class="item">新闻资讯</el-menu-item>
          <el-menu-item index="/case" class="item">开设楼盘</el-menu-item>
          <el-menu-item index="/goIn" class="item">走进民邦</el-menu-item>
        </el-menu>
      </el-header>
      <el-main>
        <router-view />
      </el-main>
      <div class="footer">
        <div class="footer-content">
          <div class="logo">
            <img src="./assets/img/horLogo.webp" alt="" />
          </div>
          <ul class="content-nav">
            <li>
              <p>新闻资讯</p>
              <span>公司新闻</span>
              <span>行业动态</span>
            </li>
            <li>
              <p>走进民邦</p>
              <span>发展历程</span>
              <span>企业文化</span>
              <span>资质荣誉</span>
              <span>合作伙伴</span>
            </li>
            <li>
              <p>联系我们</p>
              <span>邮箱：2911107728@qq.com</span>
              <span>电话：19122530926</span>
              <span>
                地址：湖北省孝感市高新技术开发区槐荫办事处东李咀社区民邦璞樾17幢601室
              </span>
            </li>
          </ul>
        </div>
        <div class="copyright">
          <span>
            ©2025
            <span>Min Bang</span>
            All Rights Reserved
          </span>
        </div>
      </div>
      <sidebar v-if="showSidebar" style="position: fixed; left: 0; top: 0" />
    </el-container>
  </div>
</template>

<script>
import Sidebar from "./components/Sidebar.vue";
export default {
  components: {
    Sidebar,
  },
  data() {
    return {
      center: {
        justifyContent: "center",
      },
      router: true,
      defaultActive: "/",
      windowWidth: document.documentElement.clientWidth,
    };
  },
  computed: {
    showSidebar() {
      return this.windowWidth < 800;
    },
  },
  mounted() {
    window.addEventListener("resize", this.handleResize);
  },
  beforeDestroy() {
    window.removeEventListener("resize", this.handleResize);
  },
  methods: {
    handleResize() {
      this.windowWidth = document.documentElement.clientWidth;
    },
  },
};
</script>

<style lang="scss" scoped>
* {
  padding: 0;
  margin: 0;
}
html,
body {
  height: 100%;
}

#app {
  font-family: "Avenir", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #2c3e50;
}

.el-header {
  display: flex;
  justify-content: space-between;
  align-content: center;
  width: 100%;
  .el-menu-demo {
    .item{
      margin: 0 20px;
    }
  }
  .logo {
    width: 180px;
    aspect-ratio: 3;
    img {
      width: 180px;
    }
  }
}
.el-main {
  padding: 0 !important;
}
.footer {
  width: 100%;
  overflow: hidden;
  background-color: #001529;
  &-content {
    width: 100%;
    margin: 0 auto;
    padding: 40px 0;
    display: flex;
    justify-content: space-around;
    align-items: center;
    .content-nav {
      display: flex;
      justify-content: space-around;
      li {
        display: flex;
        flex-direction: column;
        padding: 0 20px;
        //justify-content: center;
        align-items: flex-start;
        p {
          font-size: 20px;
          color: rgb(204, 204, 204);
          padding: 10px 0;
        }
        span {
          color: rgb(153, 153, 153);
          font-weight: 300;
          padding: 5px 0;
        }
      }
    }

    img {
      width: 18vw;
      height: 5vw;
      padding: 10px;
    }
  }
  .copyright {
    display: flex;
    justify-content: center;
    align-content: center;
    height: 30px;
    background: #001529;
    span {
      color: rgb(153, 153, 153);
      line-height: 30px;
      span {
        color: #2f54eb;
      }
    }
  }
  @media screen and (max-width: 1180px) {
    .footer {
      &-content {
        padding: 20px 0;
        .content-nav {
          display: none;
        }
        .logo {
          margin: 0;
          img {
            width: 250px;
            height: 70px;
          }
        }
      }
    }
  }
}
</style>
